home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / oleo-1_4.lha / oleo-1.4 / parse.tab.c < prev    next >
C/C++ Source or Header  |  1993-01-11  |  51KB  |  1,907 lines

  1.  
  2. /*  A Bison parser, made from parse.y  */
  3.  
  4. #define YYBISON 1  /* Identify Bison output.  */
  5.  
  6. #define    NE    258
  7. #define    LE    259
  8. #define    GE    260
  9. #define    NEG    261
  10. #define    L_CELL    262
  11. #define    L_RANGE    263
  12. #define    L_VAR    264
  13. #define    L_CONST    265
  14. #define    L_FN0    266
  15. #define    L_FN1    267
  16. #define    L_FN2    268
  17. #define    L_FN3    269
  18. #define    L_FN4    270
  19. #define    L_FNN    271
  20. #define    L_FN1R    272
  21. #define    L_FN2R    273
  22. #define    L_FN3R    274
  23. #define    L_FN4R    275
  24. #define    L_FNNR    276
  25. #define    L_LE    277
  26. #define    L_NE    278
  27. #define    L_GE    279
  28.  
  29. #line 1 "parse.y"
  30.  
  31. /*    Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
  32.  
  33. This file is part of Oleo, the GNU Spreadsheet.
  34.  
  35. Oleo is free software; you can redistribute it and/or modify
  36. it under the terms of the GNU General Public License as published by
  37. the Free Software Foundation; either version 2, or (at your option)
  38. any later version.
  39.  
  40. Oleo is distributed in the hope that it will be useful,
  41. but WITHOUT ANY WARRANTY; without even the implied warranty of
  42. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  43. GNU General Public License for more details.
  44.  
  45. You should have received a copy of the GNU General Public License
  46. along with Oleo; see the file COPYING.  If not, write to
  47. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  48. #line 41 "parse.y"
  49.  
  50. #include "funcdef.h"
  51.  
  52. #include <ctype.h>
  53.  
  54. #define obstack_chunk_alloc ck_malloc
  55. #define obstack_chunk_free free
  56. #include "obstack.h"
  57. #include "sysdef.h"
  58.  
  59. #include "global.h"
  60. #include "errors.h"
  61. #include "node.h"
  62. #include "eval.h"
  63. #include "ref.h"
  64.  
  65. int yylex ();
  66. #ifdef __STDC__
  67. void yyerror (char *);
  68. #else
  69. void yyerror ();
  70. #endif
  71. VOIDSTAR parse_hash;
  72. extern VOIDSTAR hash_find();
  73.  
  74. /* This table contains a list of the infix single-char functions */
  75. unsigned char fnin[] = {
  76.     SUM, DIFF, DIV, PROD, MOD, /* AND, OR, */ POW, EQUAL, IF, CONCAT, 0
  77. };
  78.  
  79. #define YYSTYPE _y_y_s_t_y_p_e
  80. typedef struct node *YYSTYPE;
  81. YYSTYPE parse_return;
  82. #ifdef __STDC__
  83. YYSTYPE make_list (YYSTYPE, YYSTYPE);
  84. #else
  85. YYSTYPE make_list ();
  86. #endif
  87.  
  88. char *instr;
  89. int parse_error = 0;
  90. extern struct obstack tmp_mem;
  91.  
  92.  
  93. #ifndef YYLTYPE
  94. typedef
  95.   struct yyltype
  96.     {
  97.       int timestamp;
  98.       int first_line;
  99.       int first_column;
  100.       int last_line;
  101.       int last_column;
  102.       char *text;
  103.    }
  104.   yyltype;
  105.  
  106. #define YYLTYPE yyltype
  107. #endif
  108.  
  109. #ifndef YYSTYPE
  110. #define YYSTYPE int
  111. #endif
  112. #include <stdio.h>
  113.  
  114. #ifndef __STDC__
  115. #define const
  116. #endif
  117.  
  118.  
  119.  
  120. #define    YYFINAL        131
  121. #define    YYFLAG        -32768
  122. #define    YYNTBASE    41
  123.  
  124. #define YYTRANSLATE(x) ((unsigned)(x) <= 279 ? yytranslate[x] : 47)
  125.  
  126. static const char yytranslate[] = {     0,
  127.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  128.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  129.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  130.      2,     2,    19,     2,     2,     2,    16,     5,     2,    38,
  131.     39,    14,    12,    40,    13,     2,    15,     2,     2,     2,
  132.      2,     2,     2,     2,     2,     2,     2,     4,     2,     8,
  133.      6,    10,     3,     2,     2,     2,     2,     2,     2,     2,
  134.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  135.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  136.      2,     2,     2,    17,     2,     2,     2,     2,     2,     2,
  137.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  138.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  139.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  140.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  141.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  142.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  143.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  144.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  145.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  146.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  147.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  148.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  149.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  150.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  151.      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
  152.      2,     2,     2,     2,     2,     1,     2,     7,     9,    11,
  153.     18,    20,    21,    22,    23,    24,    25,    26,    27,    28,
  154.     29,    30,    31,    32,    33,    34,    35,    36,    37
  155. };
  156.  
  157. #if YYDEBUG != 0
  158. static const short yyprhs[] = {     0,
  159.      0,     2,     4,     6,     8,    12,    17,    24,    33,    44,
  160.     49,    54,    59,    66,    73,    82,    91,   100,   109,   114,
  161.    120,   124,   128,   132,   136,   140,   144,   148,   152,   156,
  162.    160,   164,   168,   172,   175,   178,   182,   186,   189,   191,
  163.    195,   197,   199,   201,   205,   207
  164. };
  165.  
  166. #endif
  167.  
  168. static const short yyrhs[] = {    42,
  169.      0,     1,     0,    23,     0,    46,     0,    24,    38,    39,
  170.      0,    25,    38,    42,    39,     0,    26,    38,    42,    40,
  171.     42,    39,     0,    27,    38,    42,    40,    42,    40,    42,
  172.     39,     0,    28,    38,    42,    40,    42,    40,    42,    40,
  173.     42,    39,     0,    29,    38,    43,    39,     0,    30,    38,
  174.     21,    39,     0,    30,    38,    22,    39,     0,    31,    38,
  175.     21,    40,    42,    39,     0,    31,    38,    22,    40,    42,
  176.     39,     0,    31,    38,    21,    40,    42,    40,    42,    39,
  177.      0,    31,    38,    22,    40,    42,    40,    42,    39,     0,
  178.     32,    38,    21,    40,    42,    40,    42,    39,     0,    32,
  179.     38,    22,    40,    42,    40,    42,    39,     0,    34,    38,
  180.     45,    39,     0,    42,     3,    42,     4,    42,     0,    42,
  181.      5,    42,     0,    42,     8,    42,     0,    42,     9,    42,
  182.      0,    42,     6,    42,     0,    42,     7,    42,     0,    42,
  183.     10,    42,     0,    42,    11,    42,     0,    42,    12,    42,
  184.      0,    42,    13,    42,     0,    42,    14,    42,     0,    42,
  185.     15,    42,     0,    42,    16,    42,     0,    42,    17,    42,
  186.      0,    13,    42,     0,    19,    42,     0,    38,    42,    39,
  187.      0,    38,    42,     1,     0,    38,     1,     0,    42,     0,
  188.     43,    40,    42,     0,    21,     0,    42,     0,    44,     0,
  189.     45,    40,    44,     0,    20,     0,    22,     0
  190. };
  191.  
  192. #if YYDEBUG != 0
  193. static const short yyrline[] = { 0,
  194.     86,    88,    94,    95,    96,    98,   102,   106,   110,   114,
  195.    118,   121,   125,   129,   135,   142,   150,   154,   159,   163,
  196.    174,   178,   182,   186,   190,   194,   198,   202,   206,   210,
  197.    214,   218,   222,   226,   241,   245,   247,   255,   262,   264,
  198.    268,   269,   272,   274,   278,   280
  199. };
  200.  
  201. static const char * const yytname[] = {   "$","error","$illegal.","'?'","':'",
  202. "'&'","'='","NE","'<'","LE","'>'","GE","'+'","'-'","'*'","'/'","'%'","'^'","NEG",
  203. "'!'","L_CELL","L_RANGE","L_VAR","L_CONST","L_FN0","L_FN1","L_FN2","L_FN3","L_FN4",
  204. "L_FNN","L_FN1R","L_FN2R","L_FN3R","L_FN4R","L_FNNR","L_LE","L_NE","L_GE","'('",
  205. "')'","','","line","exp","exp_list","range_exp","range_exp_list","cell",""
  206. };
  207. #endif
  208.  
  209. static const short yyr1[] = {     0,
  210.     41,    41,    42,    42,    42,    42,    42,    42,    42,    42,
  211.     42,    42,    42,    42,    42,    42,    42,    42,    42,    42,
  212.     42,    42,    42,    42,    42,    42,    42,    42,    42,    42,
  213.     42,    42,    42,    42,    42,    42,    42,    42,    43,    43,
  214.     44,    44,    45,    45,    46,    46
  215. };
  216.  
  217. static const short yyr2[] = {     0,
  218.      1,     1,     1,     1,     3,     4,     6,     8,    10,     4,
  219.      4,     4,     6,     6,     8,     8,     8,     8,     4,     5,
  220.      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
  221.      3,     3,     3,     2,     2,     3,     3,     2,     1,     3,
  222.      1,     1,     1,     3,     1,     1
  223. };
  224.  
  225. static const short yydefact[] = {     0,
  226.      2,     0,     0,    45,    46,     3,     0,     0,     0,     0,
  227.      0,     0,     0,     0,     0,     0,     0,     1,     4,    34,
  228.     35,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  229.      0,    38,     0,     0,     0,     0,     0,     0,     0,     0,
  230.      0,     0,     0,     0,     0,     0,     0,     5,     0,     0,
  231.      0,     0,    39,     0,     0,     0,     0,     0,     0,     0,
  232.     41,    42,    43,     0,    37,    36,     0,    21,    24,    25,
  233.     22,    23,    26,    27,    28,    29,    30,    31,    32,    33,
  234.      6,     0,     0,     0,    10,     0,    11,    12,     0,     0,
  235.      0,     0,    19,     0,     0,     0,     0,     0,    40,     0,
  236.      0,     0,     0,    44,    20,     7,     0,     0,    13,     0,
  237.     14,     0,     0,     0,     0,     0,     0,     0,     0,     0,
  238.      8,     0,    15,    16,    17,    18,     0,     9,     0,     0,
  239.      0
  240. };
  241.  
  242. static const short yydefgoto[] = {   129,
  243.     62,    54,    63,    64,    19
  244. };
  245.  
  246. static const short yypact[] = {   104,
  247. -32768,   486,   486,-32768,-32768,-32768,   -37,   -22,   -16,    10,
  248.     12,    14,    29,    43,    47,    50,   124,   537,-32768,-32768,
  249. -32768,    59,   486,   486,   486,   486,   486,     7,     9,    11,
  250.    464,-32768,    48,   486,   486,   486,   486,   486,   486,   486,
  251.    486,   486,   486,   486,   486,   486,   486,-32768,   332,   173,
  252.    209,   224,   537,    54,    60,    61,    64,    66,    69,    71,
  253. -32768,   537,-32768,    57,-32768,-32768,   522,    -2,   193,   193,
  254.    547,   547,   547,   547,     4,     4,    84,    84,    84,    84,
  255. -32768,   486,   486,   486,-32768,   486,-32768,-32768,   486,   486,
  256.    486,   486,-32768,   464,   486,   353,   245,   260,   537,    63,
  257.    158,   281,   296,-32768,   537,-32768,   486,   486,-32768,   486,
  258. -32768,   486,   486,   486,   369,   317,   388,   404,   423,   439,
  259. -32768,   486,-32768,-32768,-32768,-32768,   458,-32768,   115,   116,
  260. -32768
  261. };
  262.  
  263. static const short yypgoto[] = {-32768,
  264.      0,-32768,    24,-32768,-32768
  265. };
  266.  
  267.  
  268. #define    YYLAST        564
  269.  
  270.  
  271. static const short yytable[] = {    18,
  272.     22,    20,    21,    36,    37,    38,    39,    40,    41,    42,
  273.     43,    44,    45,    46,    47,    23,    33,    44,    45,    46,
  274.     47,    24,    49,    50,    51,    52,    53,    55,    56,    57,
  275.     58,    59,    60,    67,    68,    69,    70,    71,    72,    73,
  276.     74,    75,    76,    77,    78,    79,    80,    25,    65,    26,
  277.     34,    27,    35,    36,    37,    38,    39,    40,    41,    42,
  278.     43,    44,    45,    46,    47,    34,    28,    35,    36,    37,
  279.     38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
  280.     29,    96,    97,    98,    30,    99,    66,    31,   100,   101,
  281.    102,   103,    85,    86,   105,    93,    94,    48,    87,    88,
  282.     47,   109,   110,    89,     1,    90,   115,   116,    91,   117,
  283.     92,   118,   119,   120,   130,   131,     2,   104,     0,     0,
  284.      0,   127,     3,     4,    32,     5,     6,     7,     8,     9,
  285.     10,    11,    12,    13,    14,    15,     2,    16,     0,     0,
  286.      0,    17,     3,     4,     0,     5,     6,     7,     8,     9,
  287.     10,    11,    12,    13,    14,    15,     0,    16,     0,     0,
  288.     34,    17,    35,    36,    37,    38,    39,    40,    41,    42,
  289.     43,    44,    45,    46,    47,    34,     0,    35,    36,    37,
  290.     38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
  291.      0,     0,     0,     0,     0,     0,   111,   112,-32768,-32768,
  292.     38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
  293.      0,    34,    82,    35,    36,    37,    38,    39,    40,    41,
  294.     42,    43,    44,    45,    46,    47,    34,     0,    35,    36,
  295.     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
  296.     47,     0,     0,     0,     0,     0,     0,    34,    83,    35,
  297.     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
  298.     46,    47,    34,    84,    35,    36,    37,    38,    39,    40,
  299.     41,    42,    43,    44,    45,    46,    47,     0,     0,     0,
  300.      0,     0,     0,    34,   107,    35,    36,    37,    38,    39,
  301.     40,    41,    42,    43,    44,    45,    46,    47,    34,   108,
  302.     35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
  303.     45,    46,    47,     0,     0,     0,     0,     0,     0,    34,
  304.    113,    35,    36,    37,    38,    39,    40,    41,    42,    43,
  305.     44,    45,    46,    47,    34,   114,    35,    36,    37,    38,
  306.     39,    40,    41,    42,    43,    44,    45,    46,    47,     0,
  307.      0,     0,     0,     0,     0,    34,   122,    35,    36,    37,
  308.     38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
  309.     81,    34,     0,    35,    36,    37,    38,    39,    40,    41,
  310.     42,    43,    44,    45,    46,    47,     0,     0,     0,     0,
  311.     34,   106,    35,    36,    37,    38,    39,    40,    41,    42,
  312.     43,    44,    45,    46,    47,     0,    34,   121,    35,    36,
  313.     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
  314.     47,     0,     0,     0,     0,    34,   123,    35,    36,    37,
  315.     38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
  316.      0,    34,   124,    35,    36,    37,    38,    39,    40,    41,
  317.     42,    43,    44,    45,    46,    47,     0,     0,     0,     0,
  318.     34,   125,    35,    36,    37,    38,    39,    40,    41,    42,
  319.     43,    44,    45,    46,    47,     0,     2,   126,     0,     0,
  320.      0,     0,     3,     4,    61,     5,     6,     7,     8,     9,
  321.     10,    11,    12,    13,    14,    15,   128,    16,     2,     0,
  322.      0,    17,     0,     0,     3,     4,     0,     5,     6,     7,
  323.      8,     9,    10,    11,    12,    13,    14,    15,     0,    16,
  324.      0,     0,     0,    17,    34,    95,    35,    36,    37,    38,
  325.     39,    40,    41,    42,    43,    44,    45,    46,    47,    34,
  326.      0,    35,    36,    37,    38,    39,    40,    41,    42,    43,
  327.     44,    45,    46,    47,-32768,-32768,-32768,-32768,    42,    43,
  328.     44,    45,    46,    47
  329. };
  330.  
  331. static const short yycheck[] = {     0,
  332.     38,     2,     3,     6,     7,     8,     9,    10,    11,    12,
  333.     13,    14,    15,    16,    17,    38,    17,    14,    15,    16,
  334.     17,    38,    23,    24,    25,    26,    27,    21,    22,    21,
  335.     22,    21,    22,    34,    35,    36,    37,    38,    39,    40,
  336.     41,    42,    43,    44,    45,    46,    47,    38,     1,    38,
  337.      3,    38,     5,     6,     7,     8,     9,    10,    11,    12,
  338.     13,    14,    15,    16,    17,     3,    38,     5,     6,     7,
  339.      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
  340.     38,    82,    83,    84,    38,    86,    39,    38,    89,    90,
  341.     91,    92,    39,    40,    95,    39,    40,    39,    39,    39,
  342.     17,    39,    40,    40,     1,    40,   107,   108,    40,   110,
  343.     40,   112,   113,   114,     0,     0,    13,    94,    -1,    -1,
  344.     -1,   122,    19,    20,     1,    22,    23,    24,    25,    26,
  345.     27,    28,    29,    30,    31,    32,    13,    34,    -1,    -1,
  346.     -1,    38,    19,    20,    -1,    22,    23,    24,    25,    26,
  347.     27,    28,    29,    30,    31,    32,    -1,    34,    -1,    -1,
  348.      3,    38,     5,     6,     7,     8,     9,    10,    11,    12,
  349.     13,    14,    15,    16,    17,     3,    -1,     5,     6,     7,
  350.      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
  351.     -1,    -1,    -1,    -1,    -1,    -1,    39,    40,     6,     7,
  352.      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
  353.     -1,     3,    40,     5,     6,     7,     8,     9,    10,    11,
  354.     12,    13,    14,    15,    16,    17,     3,    -1,     5,     6,
  355.      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
  356.     17,    -1,    -1,    -1,    -1,    -1,    -1,     3,    40,     5,
  357.      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
  358.     16,    17,     3,    40,     5,     6,     7,     8,     9,    10,
  359.     11,    12,    13,    14,    15,    16,    17,    -1,    -1,    -1,
  360.     -1,    -1,    -1,     3,    40,     5,     6,     7,     8,     9,
  361.     10,    11,    12,    13,    14,    15,    16,    17,     3,    40,
  362.      5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
  363.     15,    16,    17,    -1,    -1,    -1,    -1,    -1,    -1,     3,
  364.     40,     5,     6,     7,     8,     9,    10,    11,    12,    13,
  365.     14,    15,    16,    17,     3,    40,     5,     6,     7,     8,
  366.      9,    10,    11,    12,    13,    14,    15,    16,    17,    -1,
  367.     -1,    -1,    -1,    -1,    -1,     3,    40,     5,     6,     7,
  368.      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
  369.     39,     3,    -1,     5,     6,     7,     8,     9,    10,    11,
  370.     12,    13,    14,    15,    16,    17,    -1,    -1,    -1,    -1,
  371.      3,    39,     5,     6,     7,     8,     9,    10,    11,    12,
  372.     13,    14,    15,    16,    17,    -1,     3,    39,     5,     6,
  373.      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
  374.     17,    -1,    -1,    -1,    -1,     3,    39,     5,     6,     7,
  375.      8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
  376.     -1,     3,    39,     5,     6,     7,     8,     9,    10,    11,
  377.     12,    13,    14,    15,    16,    17,    -1,    -1,    -1,    -1,
  378.      3,    39,     5,     6,     7,     8,     9,    10,    11,    12,
  379.     13,    14,    15,    16,    17,    -1,    13,    39,    -1,    -1,
  380.     -1,    -1,    19,    20,    21,    22,    23,    24,    25,    26,
  381.     27,    28,    29,    30,    31,    32,    39,    34,    13,    -1,
  382.     -1,    38,    -1,    -1,    19,    20,    -1,    22,    23,    24,
  383.     25,    26,    27,    28,    29,    30,    31,    32,    -1,    34,
  384.     -1,    -1,    -1,    38,     3,     4,     5,     6,     7,     8,
  385.      9,    10,    11,    12,    13,    14,    15,    16,    17,     3,
  386.     -1,     5,     6,     7,     8,     9,    10,    11,    12,    13,
  387.     14,    15,    16,    17,     8,     9,    10,    11,    12,    13,
  388.     14,    15,    16,    17
  389. };
  390. /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
  391. #line 3 "/afs/andrew/usr11/lord//lib/bison.simple"
  392.  
  393. /* Skeleton output parser for bison,
  394.    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
  395.  
  396.    This program is free software; you can redistribute it and/or modify
  397.    it under the terms of the GNU General Public License as published by
  398.    the Free Software Foundation; either version 1, or (at your option)
  399.    any later version.
  400.  
  401.    This program is distributed in the hope that it will be useful,
  402.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  403.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  404.    GNU General Public License for more details.
  405.  
  406.    You should have received a copy of the GNU General Public License
  407.    along with this program; if not, write to the Free Software
  408.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  409.  
  410.  
  411. #ifndef alloca
  412. #ifdef __GNUC__
  413. #define alloca __builtin_alloca
  414. #else /* not GNU C.  */
  415. #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc)
  416. #include <alloca.h>
  417. #else /* not sparc */
  418. #if defined (MSDOS) && !defined (__TURBOC__)
  419. #include <malloc.h>
  420. #else /* not MSDOS, or __TURBOC__ */
  421. #if defined(_AIX)
  422. #include <malloc.h>
  423.  #pragma alloca
  424. #endif /* not _AIX */
  425. #endif /* not MSDOS, or __TURBOC__ */
  426. #endif /* not sparc.  */
  427. #endif /* not GNU C.  */
  428. #endif /* alloca not defined.  */
  429.  
  430. /* This is the parser code that is written into each bison parser
  431.   when the %semantic_parser declaration is not specified in the grammar.
  432.   It was written by Richard Stallman by simplifying the hairy parser
  433.   used when %semantic_parser is specified.  */
  434.  
  435. /* Note: there must be only one dollar sign in this file.
  436.    It is replaced by the list of actions, each action
  437.    as one case of the switch.  */
  438.  
  439. #define yyerrok        (yyerrstatus = 0)
  440. #define yyclearin    (yychar = YYEMPTY)
  441. #define YYEMPTY        -2
  442. #define YYEOF        0
  443. #define YYACCEPT    return(0)
  444. #define YYABORT     return(1)
  445. #define YYERROR        goto yyerrlab1
  446. /* Like YYERROR except do call yyerror.
  447.    This remains here temporarily to ease the
  448.    transition to the new meaning of YYERROR, for GCC.
  449.    Once GCC version 2 has supplanted version 1, this can go.  */
  450. #define YYFAIL        goto yyerrlab
  451. #define YYRECOVERING()  (!!yyerrstatus)
  452. #define YYBACKUP(token, value) \
  453. do                                \
  454.   if (yychar == YYEMPTY && yylen == 1)                \
  455.     { yychar = (token), yylval = (value);            \
  456.       yychar1 = YYTRANSLATE (yychar);                \
  457.       YYPOPSTACK;                        \
  458.       goto yybackup;                        \
  459.     }                                \
  460.   else                                \
  461.     { yyerror ("syntax error: cannot back up"); YYERROR; }    \
  462. while (0)
  463.  
  464. #define YYTERROR    1
  465. #define YYERRCODE    256
  466.  
  467. #ifndef YYPURE
  468. #define YYLEX        yylex()
  469. #endif
  470.  
  471. #ifdef YYPURE
  472. #ifdef YYLSP_NEEDED
  473. #define YYLEX        yylex(&yylval, &yylloc)
  474. #else
  475. #define YYLEX        yylex(&yylval)
  476. #endif
  477. #endif
  478.  
  479. /* If nonreentrant, generate the variables here */
  480.  
  481. #ifndef YYPURE
  482.  
  483. int    yychar;            /*  the lookahead symbol        */
  484. YYSTYPE    yylval;            /*  the semantic value of the        */
  485.                 /*  lookahead symbol            */
  486.  
  487. #ifdef YYLSP_NEEDED
  488. YYLTYPE yylloc;            /*  location data for the lookahead    */
  489.                 /*  symbol                */
  490. #endif
  491.  
  492. int yynerrs;            /*  number of parse errors so far       */
  493. #endif  /* not YYPURE */
  494.  
  495. #if YYDEBUG != 0
  496. int yydebug;            /*  nonzero means print parse trace    */
  497. /* Since this is uninitialized, it does not stop multiple parsers
  498.    from coexisting.  */
  499. #endif
  500.  
  501. /*  YYINITDEPTH indicates the initial size of the parser's stacks    */
  502.  
  503. #ifndef    YYINITDEPTH
  504. #define YYINITDEPTH 200
  505. #endif
  506.  
  507. /*  YYMAXDEPTH is the maximum size the stacks can grow to
  508.     (effective only if the built-in stack extension method is used).  */
  509.  
  510. #if YYMAXDEPTH == 0
  511. #undef YYMAXDEPTH
  512. #endif
  513.  
  514. #ifndef YYMAXDEPTH
  515. #define YYMAXDEPTH 10000
  516. #endif
  517.  
  518. #if __GNUC__ > 1        /* GNU C and GNU C++ define this.  */
  519. #define __yy_bcopy(FROM,TO,COUNT)    __builtin_memcpy(TO,FROM,COUNT)
  520. #else                /* not GNU C or C++ */
  521. #ifndef __cplusplus
  522.  
  523. /* This is the most reliable way to avoid incompatibilities
  524.    in available built-in functions on various systems.  */
  525. static void
  526. __yy_bcopy (from, to, count)
  527.      char *from;
  528.      char *to;
  529.      int count;
  530. {
  531.   register char *f = from;
  532.   register char *t = to;
  533.   register int i = count;
  534.  
  535.   while (i-- > 0)
  536.     *t++ = *f++;
  537. }
  538.  
  539. #else /* __cplusplus */
  540.  
  541. /* This is the most reliable way to avoid incompatibilities
  542.    in available built-in functions on various systems.  */
  543. static void
  544. __yy_bcopy (char *from, char *to, int count)
  545. {
  546.   register char *f = from;
  547.   register char *t = to;
  548.   register int i = count;
  549.  
  550.   while (i-- > 0)
  551.     *t++ = *f++;
  552. }
  553.  
  554. #endif
  555. #endif
  556.  
  557. #line 169 "/afs/andrew/usr11/lord//lib/bison.simple"
  558. int
  559. yyparse()
  560. {
  561.   register int yystate;
  562.   register int yyn;
  563.   register short *yyssp;
  564.   register YYSTYPE *yyvsp;
  565.   int yyerrstatus;    /*  number of tokens to shift before error messages enabled */
  566.   int yychar1;        /*  lookahead token as an internal (translated) token number */
  567.  
  568.   short    yyssa[YYINITDEPTH];    /*  the state stack            */
  569.   YYSTYPE yyvsa[YYINITDEPTH];    /*  the semantic value stack        */
  570.  
  571.   short *yyss = yyssa;        /*  refer to the stacks thru separate pointers */
  572.   YYSTYPE *yyvs = yyvsa;    /*  to allow yyoverflow to reallocate them elsewhere */
  573.  
  574. #ifdef YYLSP_NEEDED
  575.   YYLTYPE yylsa[YYINITDEPTH];    /*  the location stack            */
  576.   YYLTYPE *yyls = yylsa;
  577.   YYLTYPE *yylsp;
  578.  
  579. #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
  580. #else
  581. #define YYPOPSTACK   (yyvsp--, yyssp--)
  582. #endif
  583.  
  584.   int yystacksize = YYINITDEPTH;
  585.  
  586. #ifdef YYPURE
  587.   int yychar;
  588.   YYSTYPE yylval;
  589.   int yynerrs;
  590. #ifdef YYLSP_NEEDED
  591.   YYLTYPE yylloc;
  592. #endif
  593. #endif
  594.  
  595.   YYSTYPE yyval;        /*  the variable used to return        */
  596.                 /*  semantic values from the action    */
  597.                 /*  routines                */
  598.  
  599.   int yylen;
  600.  
  601. #if YYDEBUG != 0
  602.   if (yydebug)
  603.     fprintf(stderr, "Starting parse\n");
  604. #endif
  605.  
  606.   yystate = 0;
  607.   yyerrstatus = 0;
  608.   yynerrs = 0;
  609.   yychar = YYEMPTY;        /* Cause a token to be read.  */
  610.  
  611.   /* Initialize stack pointers.
  612.      Waste one element of value and location stack
  613.      so that they stay on the same level as the state stack.
  614.      The wasted elements are never initialized.  */
  615.  
  616.   yyssp = yyss - 1;
  617.   yyvsp = yyvs;
  618. #ifdef YYLSP_NEEDED
  619.   yylsp = yyls;
  620. #endif
  621.  
  622. /* Push a new state, which is found in  yystate  .  */
  623. /* In all cases, when you get here, the value and location stacks
  624.    have just been pushed. so pushing a state here evens the stacks.  */
  625. yynewstate:
  626.  
  627.   *++yyssp = yystate;
  628.  
  629.   if (yyssp >= yyss + yystacksize - 1)
  630.     {
  631.       /* Give user a chance to reallocate the stack */
  632.       /* Use copies of these so that the &'s don't force the real ones into memory. */
  633.       YYSTYPE *yyvs1 = yyvs;
  634.       short *yyss1 = yyss;
  635. #ifdef YYLSP_NEEDED
  636.       YYLTYPE *yyls1 = yyls;
  637. #endif
  638.  
  639.       /* Get the current used size of the three stacks, in elements.  */
  640.       int size = yyssp - yyss + 1;
  641.  
  642. #ifdef yyoverflow
  643.       /* Each stack pointer address is followed by the size of
  644.      the data in use in that stack, in bytes.  */
  645.       yyoverflow("parser stack overflow",
  646.          &yyss1, size * sizeof (*yyssp),
  647.          &yyvs1, size * sizeof (*yyvsp),
  648. #ifdef YYLSP_NEEDED
  649.          &yyls1, size * sizeof (*yylsp),
  650. #endif
  651.          &yystacksize);
  652.  
  653.       yyss = yyss1; yyvs = yyvs1;
  654. #ifdef YYLSP_NEEDED
  655.       yyls = yyls1;
  656. #endif
  657. #else /* no yyoverflow */
  658.       /* Extend the stack our own way.  */
  659.       if (yystacksize >= YYMAXDEPTH)
  660.     {
  661.       yyerror("parser stack overflow");
  662.       return 2;
  663.     }
  664.       yystacksize *= 2;
  665.       if (yystacksize > YYMAXDEPTH)
  666.     yystacksize = YYMAXDEPTH;
  667.       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
  668.       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
  669.       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
  670.       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
  671. #ifdef YYLSP_NEEDED
  672.       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
  673.       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
  674. #endif
  675. #endif /* no yyoverflow */
  676.  
  677.       yyssp = yyss + size - 1;
  678.       yyvsp = yyvs + size - 1;
  679. #ifdef YYLSP_NEEDED
  680.       yylsp = yyls + size - 1;
  681. #endif
  682.  
  683. #if YYDEBUG != 0
  684.       if (yydebug)
  685.     fprintf(stderr, "Stack size increased to %d\n", yystacksize);
  686. #endif
  687.  
  688.       if (yyssp >= yyss + yystacksize - 1)
  689.     YYABORT;
  690.     }
  691.  
  692. #if YYDEBUG != 0
  693.   if (yydebug)
  694.     fprintf(stderr, "Entering state %d\n", yystate);
  695. #endif
  696.  
  697.   goto yybackup;
  698.  yybackup:
  699.  
  700. /* Do appropriate processing given the current state.  */
  701. /* Read a lookahead token if we need one and don't already have one.  */
  702. /* yyresume: */
  703.  
  704.   /* First try to decide what to do without reference to lookahead token.  */
  705.  
  706.   yyn = yypact[yystate];
  707.   if (yyn == YYFLAG)
  708.     goto yydefault;
  709.  
  710.   /* Not known => get a lookahead token if don't already have one.  */
  711.  
  712.   /* yychar is either YYEMPTY or YYEOF
  713.      or a valid token in external form.  */
  714.  
  715.   if (yychar == YYEMPTY)
  716.     {
  717. #if YYDEBUG != 0
  718.       if (yydebug)
  719.     fprintf(stderr, "Reading a token: ");
  720. #endif
  721.       yychar = YYLEX;
  722.     }
  723.  
  724.   /* Convert token to internal form (in yychar1) for indexing tables with */
  725.  
  726.   if (yychar <= 0)        /* This means end of input. */
  727.     {
  728.       yychar1 = 0;
  729.       yychar = YYEOF;        /* Don't call YYLEX any more */
  730.  
  731. #if YYDEBUG != 0
  732.       if (yydebug)
  733.     fprintf(stderr, "Now at end of input.\n");
  734. #endif
  735.     }
  736.   else
  737.     {
  738.       yychar1 = YYTRANSLATE(yychar);
  739.  
  740. #if YYDEBUG != 0
  741.       if (yydebug)
  742.     {
  743.       fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
  744.       /* Give the individual parser a way to print the precise meaning
  745.          of a token, for further debugging info.  */
  746. #ifdef YYPRINT
  747.       YYPRINT (stderr, yychar, yylval);
  748. #endif
  749.       fprintf (stderr, ")\n");
  750.     }
  751. #endif
  752.     }
  753.  
  754.   yyn += yychar1;
  755.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
  756.     goto yydefault;
  757.  
  758.   yyn = yytable[yyn];
  759.  
  760.   /* yyn is what to do for this token type in this state.
  761.      Negative => reduce, -yyn is rule number.
  762.      Positive => shift, yyn is new state.
  763.        New state is final state => don't bother to shift,
  764.        just return success.
  765.      0, or most negative number => error.  */
  766.  
  767.   if (yyn < 0)
  768.     {
  769.       if (yyn == YYFLAG)
  770.     goto yyerrlab;
  771.       yyn = -yyn;
  772.       goto yyreduce;
  773.     }
  774.   else if (yyn == 0)
  775.     goto yyerrlab;
  776.  
  777.   if (yyn == YYFINAL)
  778.     YYACCEPT;
  779.  
  780.   /* Shift the lookahead token.  */
  781.  
  782. #if YYDEBUG != 0
  783.   if (yydebug)
  784.     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
  785. #endif
  786.  
  787.   /* Discard the token being shifted unless it is eof.  */
  788.   if (yychar != YYEOF)
  789.     yychar = YYEMPTY;
  790.  
  791.   *++yyvsp = yylval;
  792. #ifdef YYLSP_NEEDED
  793.   *++yylsp = yylloc;
  794. #endif
  795.  
  796.   /* count tokens shifted since error; after three, turn off error status.  */
  797.   if (yyerrstatus) yyerrstatus--;
  798.  
  799.   yystate = yyn;
  800.   goto yynewstate;
  801.  
  802. /* Do the default action for the current state.  */
  803. yydefault:
  804.  
  805.   yyn = yydefact[yystate];
  806.   if (yyn == 0)
  807.     goto yyerrlab;
  808.  
  809. /* Do a reduction.  yyn is the number of a rule to reduce with.  */
  810. yyreduce:
  811.   yylen = yyr2[yyn];
  812.   yyval = yyvsp[1-yylen]; /* implement default value of the action */
  813.  
  814. #if YYDEBUG != 0
  815.   if (yydebug)
  816.     {
  817.       int i;
  818.  
  819.       fprintf (stderr, "Reducing via rule %d (line %d), ",
  820.            yyn, yyrline[yyn]);
  821.  
  822.       /* Print the symbols being reduced, and their result.  */
  823.       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
  824.     fprintf (stderr, "%s ", yytname[yyrhs[i]]);
  825.       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
  826.     }
  827. #endif
  828.  
  829.  
  830.   switch (yyn) {
  831.  
  832. case 1:
  833. #line 87 "parse.y"
  834. { parse_return=yyvsp[0]; ;
  835.     break;}
  836. case 2:
  837. #line 88 "parse.y"
  838. {
  839.         if(!parse_error)
  840.             parse_error=PARSE_ERR;
  841.         parse_return=0; ;
  842.     break;}
  843. case 5:
  844. #line 96 "parse.y"
  845. {
  846.         yyval=yyvsp[-2]; ;
  847.     break;}
  848. case 6:
  849. #line 98 "parse.y"
  850. {
  851.         (yyvsp[-3])->n_x.v_subs[0]=yyvsp[-1];
  852.         (yyvsp[-3])->n_x.v_subs[1]=(struct node *)0;
  853.         yyval=yyvsp[-3]; ;
  854.     break;}
  855. case 7:
  856. #line 102 "parse.y"
  857. {
  858.         (yyvsp[-5])->n_x.v_subs[0]=yyvsp[-3];
  859.         (yyvsp[-5])->n_x.v_subs[1]=yyvsp[-1];
  860.         yyval=yyvsp[-5]; ;
  861.     break;}
  862. case 8:
  863. #line 106 "parse.y"
  864. {
  865.         (yyvsp[-7])->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
  866.          (yyvsp[-7])->n_x.v_subs[1]=yyvsp[-1];
  867.          yyval=yyvsp[-7];;
  868.     break;}
  869. case 9:
  870. #line 110 "parse.y"
  871. {
  872.         (yyvsp[-9])->n_x.v_subs[0]=make_list(yyvsp[-7],yyvsp[-5]);
  873.          (yyvsp[-9])->n_x.v_subs[1]=make_list(yyvsp[-3],yyvsp[-1]);
  874.          yyval=yyvsp[-9];;
  875.     break;}
  876. case 10:
  877. #line 114 "parse.y"
  878. {
  879.         (yyvsp[-3])->n_x.v_subs[0]=(struct node *)0;
  880.         (yyvsp[-3])->n_x.v_subs[1]=yyvsp[-1];
  881.         yyval=yyvsp[-3]; ;
  882.     break;}
  883. case 11:
  884. #line 118 "parse.y"
  885. {
  886.         yyvsp[-3]->n_x.v_subs[0]=yyvsp[-1];
  887.         yyval=yyvsp[-3]; ;
  888.     break;}
  889. case 12:
  890. #line 121 "parse.y"
  891. {
  892.         yyvsp[-3]->n_x.v_subs[0]=yyvsp[-1];
  893.         yyval=yyvsp[-3]; ;
  894.     break;}
  895. case 13:
  896. #line 125 "parse.y"
  897. {
  898.         yyvsp[-5]->n_x.v_subs[0]=yyvsp[-3];
  899.         yyvsp[-5]->n_x.v_subs[1]=yyvsp[-1];
  900.         yyval=yyvsp[-5]; ;
  901.     break;}
  902. case 14:
  903. #line 129 "parse.y"
  904. {
  905.         yyvsp[-5]->n_x.v_subs[0]=yyvsp[-3];
  906.         yyvsp[-5]->n_x.v_subs[1]=yyvsp[-1];
  907.         yyval=yyvsp[-5]; ;
  908.     break;}
  909. case 15:
  910. #line 135 "parse.y"
  911. {
  912.         if(yyvsp[-7]->comp_value!=F_INDEX)
  913.             parse_error=PARSE_ERR;
  914.         yyvsp[-7]->comp_value=F_INDEX2;
  915.         yyvsp[-7]->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
  916.         yyvsp[-7]->n_x.v_subs[1]=yyvsp[-1];
  917.         yyval=yyvsp[-7]; ;
  918.     break;}
  919. case 16:
  920. #line 142 "parse.y"
  921. {
  922.         if(yyvsp[-7]->comp_value!=F_INDEX)
  923.             parse_error=PARSE_ERR;
  924.         yyvsp[-7]->comp_value=F_INDEX2;
  925.         yyvsp[-7]->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
  926.         yyvsp[-7]->n_x.v_subs[1]=yyvsp[-1];
  927.         yyval=yyvsp[-7]; ;
  928.     break;}
  929. case 17:
  930. #line 150 "parse.y"
  931. {
  932.         (yyvsp[-7])->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
  933.          (yyvsp[-7])->n_x.v_subs[1]=yyvsp[-1];
  934.          yyval=yyvsp[-7];;
  935.     break;}
  936. case 18:
  937. #line 154 "parse.y"
  938. {
  939.         (yyvsp[-7])->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
  940.          (yyvsp[-7])->n_x.v_subs[1]=yyvsp[-1];
  941.          yyval=yyvsp[-7];;
  942.     break;}
  943. case 19:
  944. #line 159 "parse.y"
  945. {
  946.         (yyvsp[-3])->n_x.v_subs[0]=(struct node *)0;
  947.         (yyvsp[-3])->n_x.v_subs[1]=yyvsp[-1];
  948.         yyval=yyvsp[-3]; ;
  949.     break;}
  950. case 20:
  951. #line 163 "parse.y"
  952. {
  953.         yyvsp[-3]->comp_value=IF;
  954.         yyvsp[-3]->n_x.v_subs[0]=yyvsp[-1];
  955.         yyvsp[-3]->n_x.v_subs[1]=yyvsp[0];
  956.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-4];
  957.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[-2];
  958.         yyval=yyvsp[-3]; ;
  959.     break;}
  960. case 21:
  961. #line 174 "parse.y"
  962. {
  963.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  964.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  965.         yyval = yyvsp[-1]; ;
  966.     break;}
  967. case 22:
  968. #line 178 "parse.y"
  969. {
  970.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  971.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  972.         yyval = yyvsp[-1]; ;
  973.     break;}
  974. case 23:
  975. #line 182 "parse.y"
  976. {
  977.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  978.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  979.         yyval = yyvsp[-1]; ;
  980.     break;}
  981. case 24:
  982. #line 186 "parse.y"
  983. {
  984.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  985.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  986.         yyval = yyvsp[-1]; ;
  987.     break;}
  988. case 25:
  989. #line 190 "parse.y"
  990. {
  991.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  992.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  993.         yyval = yyvsp[-1]; ;
  994.     break;}
  995. case 26:
  996. #line 194 "parse.y"
  997. {
  998.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  999.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  1000.         yyval = yyvsp[-1]; ;
  1001.     break;}
  1002. case 27:
  1003. #line 198 "parse.y"
  1004. {
  1005.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  1006.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  1007.         yyval = yyvsp[-1]; ;
  1008.     break;}
  1009. case 28:
  1010. #line 202 "parse.y"
  1011. {
  1012.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  1013.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  1014.         yyval = yyvsp[-1]; ;
  1015.     break;}
  1016. case 29:
  1017. #line 206 "parse.y"
  1018. {
  1019.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  1020.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  1021.         yyval = yyvsp[-1]; ;
  1022.     break;}
  1023. case 30:
  1024. #line 210 "parse.y"
  1025. {
  1026.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  1027.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  1028.         yyval = yyvsp[-1]; ;
  1029.     break;}
  1030. case 31:
  1031. #line 214 "parse.y"
  1032. {
  1033.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  1034.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  1035.         yyval = yyvsp[-1]; ;
  1036.     break;}
  1037. case 32:
  1038. #line 218 "parse.y"
  1039. {
  1040.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  1041.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  1042.         yyval = yyvsp[-1]; ;
  1043.     break;}
  1044. case 33:
  1045. #line 222 "parse.y"
  1046. {
  1047.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
  1048.         yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
  1049.         yyval = yyvsp[-1]; ;
  1050.     break;}
  1051. case 34:
  1052. #line 226 "parse.y"
  1053. {
  1054.         if(yyvsp[0]->comp_value==CONST_FLT) {
  1055.             yyvsp[0]->n_x.v_float= -(yyvsp[0]->n_x.v_float);
  1056.             /* free($1); */
  1057.             yyval=yyvsp[0];
  1058.         } else if(yyvsp[0]->comp_value==CONST_INT) {
  1059.             yyvsp[0]->n_x.v_int= -(yyvsp[0]->n_x.v_int);
  1060.             /* free($1); */
  1061.             yyval=yyvsp[0];
  1062.         } else {
  1063.             yyvsp[-1]->comp_value = NEGATE;
  1064.             yyvsp[-1]->n_x.v_subs[0]=yyvsp[0];
  1065.             yyvsp[-1]->n_x.v_subs[1]=(struct node *)0;
  1066.             yyval = yyvsp[-1];
  1067.         } ;
  1068.     break;}
  1069. case 35:
  1070. #line 241 "parse.y"
  1071. {
  1072.         yyvsp[-1]->n_x.v_subs[0]=yyvsp[0];
  1073.         yyvsp[-1]->n_x.v_subs[1]=(struct node *)0;
  1074.         yyval = yyvsp[-1]; ;
  1075.     break;}
  1076. case 36:
  1077. #line 246 "parse.y"
  1078. { yyval = yyvsp[-1]; ;
  1079.     break;}
  1080. case 37:
  1081. #line 247 "parse.y"
  1082. {
  1083.         if(!parse_error)
  1084.             parse_error=NO_CLOSE;
  1085.         ;
  1086.     break;}
  1087. case 38:
  1088. #line 255 "parse.y"
  1089. {
  1090.         if(!parse_error)
  1091.             parse_error=NO_CLOSE;
  1092.         ;
  1093.     break;}
  1094. case 39:
  1095. #line 263 "parse.y"
  1096. { yyval = make_list(yyvsp[0], 0); ;
  1097.     break;}
  1098. case 40:
  1099. #line 265 "parse.y"
  1100. { yyval = make_list(yyvsp[0], yyvsp[-2]); ;
  1101.     break;}
  1102. case 43:
  1103. #line 273 "parse.y"
  1104. { yyval=make_list(yyvsp[0], 0); ;
  1105.     break;}
  1106. case 44:
  1107. #line 275 "parse.y"
  1108. { yyval=make_list(yyvsp[0],yyvsp[-2]); ;
  1109.     break;}
  1110. case 45:
  1111. #line 279 "parse.y"
  1112. { yyval=yyvsp[0]; ;
  1113.     break;}
  1114. }
  1115.    /* the action file gets copied in in place of this dollarsign */
  1116. #line 442 "/afs/andrew/usr11/lord//lib/bison.simple"
  1117.  
  1118.   yyvsp -= yylen;
  1119.   yyssp -= yylen;
  1120. #ifdef YYLSP_NEEDED
  1121.   yylsp -= yylen;
  1122. #endif
  1123.  
  1124. #if YYDEBUG != 0
  1125.   if (yydebug)
  1126.     {
  1127.       short *ssp1 = yyss - 1;
  1128.       fprintf (stderr, "state stack now");
  1129.       while (ssp1 != yyssp)
  1130.     fprintf (stderr, " %d", *++ssp1);
  1131.       fprintf (stderr, "\n");
  1132.     }
  1133. #endif
  1134.  
  1135.   *++yyvsp = yyval;
  1136.  
  1137. #ifdef YYLSP_NEEDED
  1138.   yylsp++;
  1139.   if (yylen == 0)
  1140.     {
  1141.       yylsp->first_line = yylloc.first_line;
  1142.       yylsp->first_column = yylloc.first_column;
  1143.       yylsp->last_line = (yylsp-1)->last_line;
  1144.       yylsp->last_column = (yylsp-1)->last_column;
  1145.       yylsp->text = 0;
  1146.     }
  1147.   else
  1148.     {
  1149.       yylsp->last_line = (yylsp+yylen-1)->last_line;
  1150.       yylsp->last_column = (yylsp+yylen-1)->last_column;
  1151.     }
  1152. #endif
  1153.  
  1154.   /* Now "shift" the result of the reduction.
  1155.      Determine what state that goes to,
  1156.      based on the state we popped back to
  1157.      and the rule number reduced by.  */
  1158.  
  1159.   yyn = yyr1[yyn];
  1160.  
  1161.   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
  1162.   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
  1163.     yystate = yytable[yystate];
  1164.   else
  1165.     yystate = yydefgoto[yyn - YYNTBASE];
  1166.  
  1167.   goto yynewstate;
  1168.  
  1169. yyerrlab:   /* here on detecting error */
  1170.  
  1171.   if (! yyerrstatus)
  1172.     /* If not already recovering from an error, report this error.  */
  1173.     {
  1174.       ++yynerrs;
  1175.  
  1176. #ifdef YYERROR_VERBOSE
  1177.       yyn = yypact[yystate];
  1178.  
  1179.       if (yyn > YYFLAG && yyn < YYLAST)
  1180.     {
  1181.       int size = 0;
  1182.       char *msg;
  1183.       int x, count;
  1184.  
  1185.       count = 0;
  1186.       for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  1187.         if (yycheck[x + yyn] == x)
  1188.           size += strlen(yytname[x]) + 15, count++;
  1189.       msg = (char *) malloc(size + 15);
  1190.       if (msg != 0)
  1191.         {
  1192.           strcpy(msg, "parse error");
  1193.  
  1194.           if (count < 5)
  1195.         {
  1196.           count = 0;
  1197.           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
  1198.             if (yycheck[x + yyn] == x)
  1199.               {
  1200.             strcat(msg, count == 0 ? ", expecting `" : " or `");
  1201.             strcat(msg, yytname[x]);
  1202.             strcat(msg, "'");
  1203.             count++;
  1204.               }
  1205.         }
  1206.           yyerror(msg);
  1207.           free(msg);
  1208.         }
  1209.       else
  1210.         yyerror ("parse error; also virtual memory exceeded");
  1211.     }
  1212.       else
  1213. #endif /* YYERROR_VERBOSE */
  1214.     yyerror("parse error");
  1215.     }
  1216.  
  1217.   goto yyerrlab1;
  1218. yyerrlab1:   /* here on error raised explicitly by an action */
  1219.  
  1220.   if (yyerrstatus == 3)
  1221.     {
  1222.       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
  1223.  
  1224.       /* return failure if at end of input */
  1225.       if (yychar == YYEOF)
  1226.     YYABORT;
  1227.  
  1228. #if YYDEBUG != 0
  1229.       if (yydebug)
  1230.     fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
  1231. #endif
  1232.  
  1233.       yychar = YYEMPTY;
  1234.     }
  1235.  
  1236.   /* Else will try to reuse lookahead token
  1237.      after shifting the error token.  */
  1238.  
  1239.   yyerrstatus = 3;        /* Each real token shifted decrements this */
  1240.  
  1241.   goto yyerrhandle;
  1242.  
  1243. yyerrdefault:  /* current state does not do anything special for the error token. */
  1244.  
  1245. #if 0
  1246.   /* This is wrong; only states that explicitly want error tokens
  1247.      should shift them.  */
  1248.   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
  1249.   if (yyn) goto yydefault;
  1250. #endif
  1251.  
  1252. yyerrpop:   /* pop the current state because it cannot handle the error token */
  1253.  
  1254.   if (yyssp == yyss) YYABORT;
  1255.   yyvsp--;
  1256.   yystate = *--yyssp;
  1257. #ifdef YYLSP_NEEDED
  1258.   yylsp--;
  1259. #endif
  1260.  
  1261. #if YYDEBUG != 0
  1262.   if (yydebug)
  1263.     {
  1264.       short *ssp1 = yyss - 1;
  1265.       fprintf (stderr, "Error: state stack now");
  1266.       while (ssp1 != yyssp)
  1267.     fprintf (stderr, " %d", *++ssp1);
  1268.       fprintf (stderr, "\n");
  1269.     }
  1270. #endif
  1271.  
  1272. yyerrhandle:
  1273.  
  1274.   yyn = yypact[yystate];
  1275.   if (yyn == YYFLAG)
  1276.     goto yyerrdefault;
  1277.  
  1278.   yyn += YYTERROR;
  1279.   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
  1280.     goto yyerrdefault;
  1281.  
  1282.   yyn = yytable[yyn];
  1283.   if (yyn < 0)
  1284.     {
  1285.       if (yyn == YYFLAG)
  1286.     goto yyerrpop;
  1287.       yyn = -yyn;
  1288.       goto yyreduce;
  1289.     }
  1290.   else if (yyn == 0)
  1291.     goto yyerrpop;
  1292.  
  1293.   if (yyn == YYFINAL)
  1294.     YYACCEPT;
  1295.  
  1296. #if YYDEBUG != 0
  1297.   if (yydebug)
  1298.     fprintf(stderr, "Shifting error token, ");
  1299. #endif
  1300.  
  1301.   *++yyvsp = yylval;
  1302. #ifdef YYLSP_NEEDED
  1303.   *++yylsp = yylloc;
  1304. #endif
  1305.  
  1306.   yystate = yyn;
  1307.   goto yynewstate;
  1308. }
  1309. #line 282 "parse.y"
  1310.  
  1311.  
  1312. void
  1313. yyerror FUN1(char *, s)
  1314. {
  1315.     if(!parse_error)
  1316.         parse_error=PARSE_ERR;
  1317. }
  1318.  
  1319. YYSTYPE
  1320. make_list FUN2(YYSTYPE, car, YYSTYPE, cdr)
  1321. {
  1322.     YYSTYPE ret;
  1323.  
  1324.     ret=(YYSTYPE)obstack_alloc(&tmp_mem,sizeof(*ret));
  1325.     ret->comp_value = 0;
  1326.     ret->n_x.v_subs[0]=car;
  1327.     ret->n_x.v_subs[1]=cdr;
  1328.     return ret;
  1329. }
  1330.  
  1331. #define ERROR -1
  1332.  
  1333. extern struct node *yylval;
  1334.  
  1335. #ifdef __STDC__
  1336. unsigned char parse_cell_or_range (char **,struct rng *);
  1337. int str_to_col (char ** str);
  1338. #else
  1339. unsigned char parse_cell_or_range ();
  1340. #endif
  1341.  
  1342. int
  1343. yylex FUN0()
  1344. {
  1345.     int ch;
  1346.     struct node *new;
  1347.     int isflt;
  1348.     char *begin;
  1349.     char *tmp_str;
  1350.     unsigned char byte_value;
  1351.     int n;
  1352.  
  1353.     /* unsigned char *ptr; */
  1354.     int nn;
  1355.     struct function *fp;
  1356.     int tmp_ch;
  1357.  
  1358. #ifdef TEST
  1359.     if(!instr)
  1360.         return ERROR;
  1361. #endif
  1362.     while(isspace(*instr))
  1363.         instr++;
  1364.     ch = *instr++;
  1365.     if(ch=='(' || ch==',' || ch==')')
  1366.         return ch;
  1367.  
  1368.     new=(struct node *)obstack_alloc(&tmp_mem,sizeof(struct node));
  1369.     new->add_byte=0;
  1370.     new->sub_value=0;
  1371.     switch(ch) {
  1372.     case 0:
  1373.         return 0;
  1374.  
  1375.     case '0': case '1': case '2': case '3': case '4': case '5': case '6':
  1376.     case '7': case '8': case '9': case '.':
  1377.         isflt = (ch=='.');
  1378.  
  1379.         begin=instr-1;
  1380.         tmp_str=instr;
  1381.  
  1382.         while(isdigit(*tmp_str) || (!isflt && *tmp_str=='.' && ++isflt))
  1383.             tmp_str++;
  1384.         if(*tmp_str=='e' || *tmp_str=='E') {
  1385.             isflt=1;
  1386.             tmp_str++;
  1387.             if(*tmp_str=='-' || *tmp_str=='+')
  1388.                 tmp_str++;
  1389.             while(isdigit(*tmp_str))
  1390.                 tmp_str++;
  1391.         }
  1392.         if(isflt) {
  1393.             new->n_x.v_float=astof((char **)(&begin));
  1394.             byte_value=CONST_FLT;
  1395.         } else {
  1396.             new->n_x.v_int=astol((char **)(&begin));
  1397.             if(begin!=tmp_str) {
  1398.                 begin=instr-1;
  1399.                 new->n_x.v_float=astof((char **)(&begin));
  1400.                 byte_value=CONST_FLT;
  1401.             } else
  1402.                 byte_value=CONST_INT;
  1403.         }
  1404.         ch=L_CONST;
  1405.         instr=begin;
  1406.         break;
  1407.  
  1408.     case '"':
  1409.         begin=instr;
  1410.         while(*instr && *instr!='"') {
  1411.             if(*instr=='\\' && instr[1])
  1412.                 instr++;
  1413.             instr++;
  1414.         }
  1415.         if(!*instr) {
  1416.             parse_error=NO_QUOTE;
  1417.             return ERROR;
  1418.         }
  1419.         tmp_str=new->n_x.v_string=(char *)ck_malloc(1+instr-begin);
  1420.         while(begin!=instr) {
  1421.             unsigned char n;
  1422.  
  1423.             if(*begin=='\\') {
  1424.                 begin++;
  1425.                 if(begin[0]>='0' && begin[0]<='7') {
  1426.                     if(begin[1]>='0' && begin[1]<='7') {
  1427.                         if(begin[2]>='0' && begin[2]<='7') {
  1428.                             n=(begin[2]-'0') + (010 * (begin[1]-'0')) + ( 0100 * (begin[0]-'0'));
  1429.                             begin+=3;
  1430.                         } else {
  1431.                             n=(begin[1]-'0') + (010 * (begin[0]-'0'));
  1432.                             begin+=2;
  1433.                         }
  1434.                     } else {
  1435.                         n=begin[0]-'0';
  1436.                         begin++;
  1437.                     }
  1438.                 } else
  1439.                     n= *begin++;
  1440.                 *tmp_str++= n;
  1441.             } else
  1442.                 *tmp_str++= *begin++;
  1443.         }
  1444.         *tmp_str='\0';
  1445.         instr++;
  1446.         byte_value=CONST_STR;
  1447.         ch=L_CONST;
  1448.         break;
  1449.  
  1450.     case '+':    case '-':
  1451.  
  1452.     case '*':    case '/':    case '%':    case '&':
  1453.     /* case '|': */    case '^':    case '=':
  1454.  
  1455.     case '?':
  1456.     {
  1457.         unsigned char *ptr;
  1458.  
  1459.         for(ptr= fnin;*ptr;ptr++)
  1460.             if(the_funs[*ptr].fn_str[0]==ch)
  1461.                 break;
  1462. #ifdef TEST
  1463.         if(!*ptr)
  1464.             panic("Can't find fnin[] entry for '%c'",ch);
  1465. #endif
  1466.         byte_value= *ptr;
  1467.     }
  1468.         break;
  1469.  
  1470.     case ':':
  1471.         byte_value=IF;
  1472.         break;
  1473.  
  1474.     case '!':
  1475.     case '<':
  1476.     case '>':
  1477.         if(*instr!='=') {
  1478.             byte_value = (ch=='<') ? LESS : (ch=='>') ? GREATER : NOT;
  1479.             break;
  1480.         }
  1481.         instr++;
  1482.         byte_value = (ch=='<') ? LESSEQ : (ch=='>') ? GREATEQ : NOTEQUAL;
  1483.         ch = (ch=='<') ? LE : (ch=='>') ? GE : NE;
  1484.         break;
  1485.  
  1486.     case '\'':
  1487.     case ';':
  1488.     case '[':
  1489.     case '\\':
  1490.     case ']':
  1491.     case '`':
  1492.     case '{':
  1493.     case '}':
  1494.     case '~':
  1495.     bad_chr:
  1496.         parse_error=BAD_CHAR;
  1497.         return ERROR;
  1498.  
  1499.     case '#':
  1500.         begin=instr-1;
  1501.         while(*instr && (isalnum(*instr) || *instr=='_'))
  1502.             instr++;
  1503.         ch= *instr;
  1504.         *instr=0;
  1505.         if(!stricmp(begin,tname))
  1506.             byte_value=F_TRUE;
  1507.         else if(!stricmp(begin,fname))
  1508.             byte_value=F_FALSE;
  1509.         else if(!stricmp(begin,iname) && (begin[4]==0 || !stricmp(begin+4,"inity")))
  1510.             byte_value=CONST_INF;
  1511.         else if(!stricmp(begin,mname) ||
  1512.             !stricmp(begin,"#ninf"))
  1513.             byte_value=CONST_NINF;
  1514.         else if(!stricmp(begin,nname) ||
  1515.             !stricmp(begin,"#nan"))
  1516.             byte_value=CONST_NAN;
  1517.         else {
  1518.             for(n=1;n<=ERR_MAX;n++)
  1519.                 if(!stricmp(begin,ename[n]))
  1520.                     break;
  1521.             if(n>ERR_MAX)
  1522.                 n=BAD_CHAR;
  1523.             new->n_x.v_int=n;
  1524.             byte_value=CONST_ERR;
  1525.         }
  1526.         *instr=ch;
  1527.         ch=L_CONST;
  1528.         break;
  1529.  
  1530.     default:
  1531.         if(!a0 && (ch=='@' || ch=='$'))
  1532.            goto bad_chr;
  1533.  
  1534.         if(a0 && ch=='@') {
  1535.             begin=instr;
  1536.             while(*instr && (isalpha(*instr) || isdigit(*instr) || *instr=='_'))
  1537.                 instr++;
  1538.             n=instr-begin;
  1539.         } else {
  1540.             begin=instr-1;
  1541.             byte_value=parse_cell_or_range(&begin,&(new->n_x.v_rng));
  1542.             if(byte_value) {
  1543.                 if((byte_value& ~0x3)==R_CELL)
  1544.                     ch=L_CELL;
  1545.                 else
  1546.                     ch=L_RANGE;
  1547.                 instr=begin;
  1548.                 break;
  1549.             }
  1550.  
  1551.             while(*instr && (isalpha(*instr) || isdigit(*instr) || *instr=='_'))
  1552.                 instr++;
  1553.  
  1554.             n=instr-begin;
  1555.             while(isspace(*instr))
  1556.                 instr++;
  1557.  
  1558.             if(*instr!='(') {
  1559.                 ch=L_VAR;
  1560.                 byte_value=VAR;
  1561.                 new->n_x.v_var=find_or_make_var(begin,n);
  1562.                 break;
  1563.             }
  1564.         }
  1565.         tmp_ch=begin[n];
  1566.         begin[n]='\0';
  1567.         fp=hash_find(parse_hash,begin);
  1568.         begin[n]=tmp_ch;
  1569.         byte_value= ERROR;
  1570.         if(!fp) {
  1571.             parse_error=BAD_FUNC;
  1572.             return ERROR;
  1573.         }
  1574.  
  1575.         if(fp>=the_funs && fp<=&the_funs[USR1])
  1576.             byte_value=fp-the_funs;
  1577.         else {
  1578.             for(nn=0;nn<n_usr_funs;nn++) {
  1579.                 if(fp>=&usr_funs[nn][0] && fp<=&usr_funs[nn][usr_n_funs[nn]]) {
  1580.                     byte_value=USR1+nn;
  1581.                     new->sub_value=fp-&usr_funs[nn][0];
  1582.                     break;
  1583.                 }
  1584.             }
  1585. #ifdef TEST
  1586.             if(nn==n_usr_funs) {
  1587.                 io_error_msg("Couln't turn fp into a ##");
  1588.                 parse_error=BAD_FUNC;
  1589.                 return ERROR;
  1590.             }
  1591. #endif
  1592.         }
  1593.  
  1594.         if(fp->fn_argn&X_J)
  1595.             ch= byte_value==F_IF ? L_FN3 : L_FN2;
  1596.         else if(fp->fn_argt[0]=='R' || fp->fn_argt[0]=='E')
  1597.             ch=L_FN1R-1+fp->fn_argn-X_A0;
  1598.         else
  1599.             ch=L_FN0 + fp->fn_argn-X_A0;
  1600.  
  1601.         break;
  1602.     }
  1603.     /* new->node_type=ch; */
  1604.     new->comp_value=byte_value;
  1605.     yylval=new;
  1606.     return ch;
  1607. }
  1608.  
  1609. /* Return value is
  1610.     0 if it doesn't look like a cell or a range,
  1611.     R_CELL if it is a cell (ptr now points past the characters, lr and lc hold the row and col of the cell)
  1612.     RANGE if it is a range (ptr points past the chars)
  1613.  */
  1614. unsigned char
  1615. parse_cell_or_range FUN2(char **,ptr, struct rng *,retp)
  1616. {
  1617.     if(a0) {
  1618.         unsigned tmpc,tmpr;
  1619.         char *p;
  1620.         int abz = ROWREL|COLREL;
  1621.  
  1622.         p= *ptr;
  1623.         tmpc=0;
  1624.         if(*p=='$') {
  1625.             abz-=COLREL;
  1626.             p++;
  1627.         }
  1628.         if(!isalpha(*p))
  1629.             return 0;
  1630.         tmpc=str_to_col(&p);
  1631.         if(tmpc<MIN_COL || tmpc>MAX_COL)
  1632.             return 0;
  1633.         if(*p=='$') {
  1634.             abz-=ROWREL;
  1635.             p++;
  1636.         }
  1637.         if(!isdigit(*p))
  1638.             return 0;
  1639.         for(tmpr=0;isdigit(*p);p++)
  1640.             tmpr=tmpr*10 + *p - '0';
  1641.  
  1642.         if(tmpr<MIN_ROW || tmpr>MAX_ROW)
  1643.             return 0;
  1644.  
  1645.         if(*p==':' || *p=='.') {
  1646.             unsigned tmpc1,tmpr1;
  1647.  
  1648.             abz = ((abz&COLREL) ? LCREL : 0)|((abz&ROWREL) ? LRREL : 0)|HRREL|HCREL;
  1649.             p++;
  1650.             if(*p=='$') {
  1651.                 abz-=HCREL;
  1652.                 p++;
  1653.             }
  1654.             if(!isalpha(*p))
  1655.                 return 0;
  1656.             tmpc1=str_to_col(&p);
  1657.             if(tmpc1<MIN_COL || tmpc1>MAX_COL)
  1658.                 return 0;
  1659.             if(*p=='$') {
  1660.                 abz-=HRREL;
  1661.                 p++;
  1662.             }
  1663.             if(!isdigit(*p))
  1664.                 return 0;
  1665.             for(tmpr1=0;isdigit(*p);p++)
  1666.                 tmpr1=tmpr1*10 + *p - '0';
  1667.             if(tmpr1<MIN_ROW || tmpr1>MAX_ROW)
  1668.                 return 0;
  1669.  
  1670.             if(tmpr<tmpr1) {
  1671.                 retp->lr=tmpr;
  1672.                 retp->hr=tmpr1;
  1673.             } else {
  1674.                 retp->lr=tmpr1;
  1675.                 retp->hr=tmpr;
  1676.             }
  1677.             if(tmpc<tmpc1) {
  1678.                 retp->lc=tmpc;
  1679.                 retp->hc=tmpc1;
  1680.             } else {
  1681.                 retp->lc=tmpc1;
  1682.                 retp->hc=tmpc;
  1683.             }
  1684.             *ptr= p;
  1685.             return RANGE | abz;
  1686.         }
  1687.         retp->lr = retp->hr = tmpr;
  1688.         retp->lc = retp->hc = tmpc;
  1689.         *ptr=p;
  1690.         return R_CELL | abz;
  1691.     } else {
  1692.         char *p;
  1693.         unsigned char retr;
  1694.         unsigned char retc;
  1695.         int ended;
  1696.         long num;
  1697.         CELLREF tmp;
  1698.  
  1699. #define CK_ABS_R(x)    ((x)<MIN_ROW || (x)>MAX_ROW)
  1700.  
  1701. #define CK_REL_R(x)    (((x)>0 && MAX_ROW-(x)<cur_row) \
  1702.              || ((x)<0 && MIN_ROW-(x)>cur_row)) 
  1703.  
  1704. #define CK_ABS_C(x)    ((x)<MIN_COL || (x)>MAX_COL)
  1705.  
  1706. #define CK_REL_C(x)    (((x)>0 && MAX_COL-(x)<cur_col)    \
  1707.              || ((x)<0 && MIN_COL-(x)>cur_col))
  1708.  
  1709. #define MAYBEREL(p) (*(p)=='[' && (isdigit((p)[1]) || (((p)[1]=='+' || (p)[1]=='-') && isdigit((p)[2]))))
  1710.  
  1711.         p= *ptr;
  1712.         retr=0;
  1713.         retc=0;
  1714.         ended=0;
  1715.         while(ended==0) {
  1716.             switch(*p) {
  1717.             case 'r':
  1718.             case 'R':
  1719.                 if(retr) {
  1720.                     ended++;
  1721.                     break;
  1722.                 }
  1723.                 p++;
  1724.                 retr=R_CELL;
  1725.                 if(isdigit(*p)) {
  1726.                     num=astol(&p);
  1727.                     if (CK_ABS_R(num))
  1728.                       return 0;
  1729.                     retp->lr= retp->hr=num;
  1730.                 } else if(MAYBEREL(p)) {
  1731.                     p++;
  1732.                     num=astol(&p);
  1733.                     if (CK_REL_R(num))
  1734.                       return 0;
  1735.                     retp->lr= retp->hr=num+cur_row;
  1736.                     retr|=ROWREL;
  1737.                     if(*p==':') {
  1738.                         retr=RANGE|LRREL|HRREL;
  1739.                         p++;
  1740.                         num=astol(&p);
  1741.                         if (CK_REL_R(num))
  1742.                           return 0;
  1743.                         retp->hr=num+cur_row;
  1744.                     }
  1745.                     if(*p++!=']')
  1746.                         return 0;
  1747.                 } else if(retc || *p=='c' || *p=='C') {
  1748.                     retr|=ROWREL;
  1749.                     retp->lr= retp->hr=cur_row;
  1750.                 } else
  1751.                     return 0;
  1752.                 if(*p==':' && retr!=(RANGE|LRREL|HRREL)) {
  1753.                     retr= (retr&ROWREL) ? RANGE|LRREL : RANGE;
  1754.                     p++;
  1755.                     if(isdigit(*p)) {
  1756.                         num=astol(&p);
  1757.                         if (CK_ABS_R(num))
  1758.                           return 0;
  1759.                          retp->hr=num;
  1760.                     } else if(MAYBEREL(p)) {
  1761.                         p++;
  1762.                         num=astol(&p);
  1763.                         if (CK_REL_R(num))
  1764.                           return 0;
  1765.                         retp->hr=num+cur_row;
  1766.                         retr|=HRREL;
  1767.                         if(*p++!=']')
  1768.                             return 0;
  1769.                     } else
  1770.                         return 0;
  1771.                 }
  1772.  
  1773.                 if(retc)
  1774.                     ended++;
  1775.                 break;
  1776.  
  1777.             case 'c':
  1778.             case 'C':
  1779.                 if(retc) {
  1780.                     ended++;
  1781.                     break;
  1782.                 }
  1783.                 p++;
  1784.                 retc=R_CELL;
  1785.                 if(isdigit(*p)) {
  1786.                     num=astol(&p);
  1787.                     if (CK_ABS_C(num))
  1788.                       return 0;
  1789.                     retp->lc= retp->hc=num;
  1790.                 } else if(MAYBEREL(p)) {
  1791.                     p++;
  1792.                     num=astol(&p);
  1793.                     if (CK_REL_C(num))
  1794.                       return 0;
  1795.                     retp->lc= retp->hc=num+cur_col;
  1796.                     retc|=COLREL;
  1797.                     if(*p==':') {
  1798.                         retc=RANGE|LCREL|HCREL;
  1799.                         p++;
  1800.                         num=astol(&p);
  1801.                         if (CK_REL_C(num))
  1802.                           return 0;
  1803.                         retp->hc=num+cur_col;
  1804.                     }
  1805.                     if(*p++!=']')
  1806.                         return 0;
  1807.                 } else if(retr || *p=='r' || *p=='R') {
  1808.                     retc|=COLREL;
  1809.                     retp->lc= retp->hc=cur_col;
  1810.                 } else
  1811.                     return 0;
  1812.                 if(*p==':' && retc!=(RANGE|LCREL|HCREL)) {
  1813.                     retc= (retc&COLREL) ? RANGE|LCREL : RANGE;
  1814.                     p++;
  1815.                     if(isdigit(*p)) {
  1816.                         num=astol(&p);
  1817.                         if (CK_ABS_C(num))
  1818.                           return 0;
  1819.                          retp->hc=num;
  1820.                     } else if(MAYBEREL(p)) {
  1821.                         p++;
  1822.                         num=astol(&p);
  1823.                         if (CK_REL_C(num))
  1824.                           return 0;
  1825.                         retp->hc=num+cur_col;
  1826.                         retc|=HCREL;
  1827.                         if(*p++!=']')
  1828.                             return 0;
  1829.                     } else
  1830.                         return 0;
  1831.                 }
  1832.  
  1833.                 if(retr)
  1834.                     ended++;
  1835.                 break;
  1836.             default:
  1837.                 if(retr) {
  1838.                     *ptr=p;
  1839.                     retp->lc=MIN_COL;
  1840.                     retp->hc=MAX_COL;
  1841.                     if((retr|ROWREL)==(R_CELL|ROWREL))
  1842.                         return (retr&ROWREL) ? (RANGE|LRREL|HRREL) : RANGE;
  1843.                     else
  1844.                         return retr;
  1845.                 } else if(retc) {
  1846.                     *ptr=p;
  1847.                     retp->lr=MIN_ROW;
  1848.                     retp->hr=MAX_COL;
  1849.                     if((retc|COLREL)==(R_CELL|COLREL))
  1850.                         return (retc&COLREL) ? (RANGE|LCREL|HCREL) : RANGE;
  1851.                     else
  1852.                         return retc;
  1853.                 }
  1854.                 return 0;
  1855.             }
  1856.         }
  1857.         if(!retr || !retc)
  1858.             return 0;
  1859.         *ptr=p;
  1860.         if(retp->lr>retp->hr)
  1861.             tmp=retp->lr,retp->lr=retp->hr,retp->hr=tmp;
  1862.         if(retp->lc>retp->hc)
  1863.             tmp=retp->lc,retp->lc=retp->hc,retp->hc=tmp;
  1864.  
  1865.         if((retr|ROWREL)==(R_CELL|ROWREL)) {
  1866.             if((retc|COLREL)==(R_CELL|COLREL))
  1867.                 return retr|retc;
  1868.             return (retr&ROWREL) ? (retc|LRREL|HRREL) : retc;
  1869.         }
  1870.         if((retc|COLREL)==(R_CELL|COLREL))
  1871.             return (retc&COLREL) ? (retr|LCREL|HCREL) : retr;
  1872.         return retr|retc;
  1873.     }
  1874. }
  1875.  
  1876. int
  1877. str_to_col FUN1(char **,str)
  1878. {
  1879.     int ret;
  1880.     char c,cc,ccc;
  1881. #if MAX_COL>702
  1882.     char cccc;
  1883. #endif
  1884.  
  1885.     ret=0;
  1886.     c=str[0][0];
  1887.     if(!isalpha((cc=str[0][1]))) {
  1888.         (*str)++;
  1889.         return MIN_COL + (isupper(c) ? c-'A' : c-'a');
  1890.     }
  1891.     if(!isalpha((ccc=str[0][2]))) {
  1892.         (*str)+=2;
  1893.         return MIN_COL+26 + (isupper(c) ? c-'A' : c-'a')*26 + (isupper(cc) ? cc-'A' : cc-'a');
  1894.     }
  1895. #if MAX_COL>702
  1896.     if(!isalpha((cccc=str[0][3]))) {
  1897.         (*str)+=3;
  1898.         return MIN_COL+702 + (isupper(c) ? c-'A' : c-'a')*26*26 + (isupper(cc) ? cc-'A' : cc-'a')*26 + (isupper(ccc) ? ccc-'A' : ccc-'a');
  1899.     }
  1900.     if(!isalpha(str[0][4])) {
  1901.         (*str)+=4;
  1902.         return MIN_COL+18278 + (isupper(c) ? c-'A' : c-'a')*26*26*26 + (isupper(cc) ? cc-'A' : cc-'a')*26*26 + (isupper(ccc) ? ccc-'A' : ccc-'a')*26 + (isupper(cccc) ? cccc-'A' : cccc-'a');
  1903.     }
  1904. #endif
  1905.     return 0;
  1906. }
  1907.